﻿namespace IPMS.BLL
{
    using IPMS.DAL;
    using System;
    using System.Data;
    using System.Data.SqlClient;

    public class ProductsClass
    {
        private DateTime _CreateDate;
        private DateTime _DateFld1;
        private DateTime _DateFld2;
        private DateTime _DateFld3;
        private DateTime _DateFld4;
        private DateTime _DateFld5;
        private string _DeciFld1;
        private string _DeciFld2;
        private string _ModelName;
        private string _ProjectGroupID;
        private string _Remark1;
        private string _Remark2;
        private string _Remark3;
        private string _Remark4;
        private string _Remark5;
        private string _Revision;
        private string _Specification;

        public int GetProductInfo(string model)
        {
            SqlCommand sqlCmd = new SqlCommand();
            DataAccessLayer DAL = new DataAccessLayer();
            DAL.AddParamToSQLCmd(sqlCmd, "@ReturnValue", SqlDbType.Int, 0, ParameterDirection.ReturnValue, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Model", SqlDbType.NVarChar, 30, ParameterDirection.Input, model);
            DAL.AddParamToSQLCmd(sqlCmd, "@ModelName", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Revision", SqlDbType.NVarChar, 30, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Specification", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@ProjectGroupID", SqlDbType.NVarChar, 30, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Remark1", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Remark2", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Remark3", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Remark4", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@Remark5", SqlDbType.NVarChar, 100, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@DateFld1", SqlDbType.DateTime, 8, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@DateFld2", SqlDbType.DateTime, 8, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@DateFld3", SqlDbType.DateTime, 8, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@DateFld4", SqlDbType.DateTime, 8, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@DateFld5", SqlDbType.DateTime, 8, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@DeciFld1", SqlDbType.NVarChar, 30, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@DeciFld2", SqlDbType.NVarChar, 30, ParameterDirection.Output, null);
            DAL.AddParamToSQLCmd(sqlCmd, "@CreateDate", SqlDbType.DateTime, 8, ParameterDirection.Output, null);
            DAL.SetCommandType(sqlCmd, CommandType.StoredProcedure, "RetrieveProductSp");
            DAL.ExecuteScalarCmd(sqlCmd);
            int resultValue = (int) sqlCmd.Parameters["@ReturnValue"].Value;
            this._ModelName = (string) sqlCmd.Parameters["@ModelName"].Value;
            this._Revision = (string) sqlCmd.Parameters["@Revision"].Value;
            this._Specification = (string) sqlCmd.Parameters["@Specification"].Value;
            this._ProjectGroupID = (string) sqlCmd.Parameters["@ProjectGroupID"].Value;
            this._Remark1 = (string) sqlCmd.Parameters["@Remark1"].Value;
            this._Remark2 = (string) sqlCmd.Parameters["@Remark2"].Value;
            this._Remark3 = (string) sqlCmd.Parameters["@Remark3"].Value;
            this._Remark4 = (string) sqlCmd.Parameters["@Remark4"].Value;
            this._Remark5 = (string) sqlCmd.Parameters["@Remark5"].Value;
            this._DateFld1 = (DateTime) sqlCmd.Parameters["@DateFld1"].Value;
            this._DateFld2 = (DateTime) sqlCmd.Parameters["@DateFld2"].Value;
            this._DateFld3 = (DateTime) sqlCmd.Parameters["@DateFld3"].Value;
            this._DateFld4 = (DateTime) sqlCmd.Parameters["@DateFld4"].Value;
            this._DateFld5 = (DateTime) sqlCmd.Parameters["@DateFld5"].Value;
            this._DeciFld1 = (string) sqlCmd.Parameters["@DeciFld1"].Value;
            this._DeciFld2 = (string) sqlCmd.Parameters["@DeciFld2"].Value;
            this._CreateDate = (DateTime) sqlCmd.Parameters["@CreateDate"].Value;
            return resultValue;
        }

        public DateTime CreateDate
        {
            get
            {
                return this._CreateDate;
            }
        }

        public DateTime DateFld1
        {
            get
            {
                return this._DateFld1;
            }
        }

        public DateTime DateFld2
        {
            get
            {
                return this._DateFld2;
            }
        }

        public DateTime DateFld3
        {
            get
            {
                return this._DateFld3;
            }
        }

        public DateTime DateFld4
        {
            get
            {
                return this._DateFld4;
            }
        }

        public DateTime DateFld5
        {
            get
            {
                return this._DateFld5;
            }
        }

        public string DeciFld1
        {
            get
            {
                return this._DeciFld1;
            }
        }

        public string DeciFld2
        {
            get
            {
                return this._DeciFld2;
            }
        }

        public string ModelName
        {
            get
            {
                return this._ModelName;
            }
        }

        public string ProjectGroupId
        {
            get
            {
                return this._ProjectGroupID;
            }
        }

        public string Remark1
        {
            get
            {
                return this._Remark1;
            }
        }

        public string Remark2
        {
            get
            {
                return this._Remark2;
            }
        }

        public string Remark3
        {
            get
            {
                return this._Remark3;
            }
        }

        public string Remark4
        {
            get
            {
                return this._Remark4;
            }
        }

        public string Remark5
        {
            get
            {
                return this._Remark5;
            }
        }

        public string Revision
        {
            get
            {
                return this._Revision;
            }
        }

        public string Specification
        {
            get
            {
                return this._Specification;
            }
        }
    }
}

